<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .change {
            outline: none;
            border: 1px solid pink;
        }
    </style>
</head>

<body>
    <input type="text" value="邮箱/ID/手机号">
    <input type="text" value="密码" class="ipt2">
    <script>
        // 1. 获取元素
        var ipt = document.querySelector('input');
        var ipt2 = document.querySelector('.ipt2');
        // 2. 注册事件
        ipt.onfocus = function() {
            if (this.value === '邮箱/ID/手机号') {
                this.value = '';
            }
            this.className = 'change'
        }
        ipt2.onfocus = function() {
            if (this.value === '密码') {
                this.value = '';
            }
            this.className = 'change'
        }
    </script>
</body>

</html>